//
//  BlockAsFuncParamController.m
//  BlockTest
//
//  Created by 崔宝印 on 2017/12/11.
//  Copyright © 2017年 Koolearn. All rights reserved.
//

#import "BlockAsFuncParamController.h"

@interface BlockAsFuncParamController ()
@end

@implementation BlockAsFuncParamController

NSMutableArray *gloableArray;

- (void)viewDidLoad
{
    [super viewDidLoad];
//    gloableArray = [NSMutableArray array];
//    [gloableArray addObject:^(int m){NSLog(@"5:%d",5*m);}];
//    [gloableArray addObject:^(int m){NSLog(@"6:%d",6*m);}];
    self.array = [self testArray];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    ParamTestBlock block1 = self.array[0];
    ParamTestBlock block2 = self.array[1];
    block1(10);
    block2(10);
    
//    [self logArray];

//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        [self logArray];
//    });
}

- (void)logArray
{
    NSArray *testArray = [self testArray];
    ParamTestBlock block1 = testArray[0];
    ParamTestBlock block2 = testArray[1];
    block1(10);
    block2(10);
}

#pragma mark - Getter
- (NSMutableArray *)array
{
    if (_array == nil)
    {
        _array = [NSMutableArray array];
    }
    return _array;
}

- (NSArray *)testArray
{
//    NSMutableArray *testArray = [NSMutableArray array];
//    [testArray addObject:^(int m){NSLog(@"1:%d",1*m);}];
//    [testArray addObject:^(int m){NSLog(@"2:%d",2*m);}];
//    return testArray;
//
    return [NSArray arrayWithObjects:^(int m){NSLog(@"1:%d",1*m);},^(int m){NSLog(@"2:%d",2*m);}, nil];
}
@end
